package com.example.mobile2021606129ly0618;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private RecyclerView rvMainUsers;
    private Button btnMainInsert;
    private List<Users>list=new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        list=new MyDateAdapter().QueryAll(this);
        rvMainUsers.setAdapter(new UserRViewAdapter(list));

        btnMainInsert.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new AlertDialog.Builder(MainActivity.this)
                        .setTitle("添加数据")
                        .setPositiveButton("添加", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {

                            }
                        }).setPositiveButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }
                })
                        .create()
                        .show();
                }
        });




    }
    private void initView(){
        rvMainUsers=(RecyclerView)findViewById(R.id.rvMainUsers);
        btnMainInsert=(Button)findViewById(R.id.btnMainInsert);
        rvMainUsers.setLayoutManager(new LinearLayoutManager(this));
    }
}